<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SCL-90心理健康自评量表</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            line-height: 1.6;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            text-align: center;
            padding: 40px 20px;
        }
        
        h1 {
            font-size: 2.5em;
            margin-bottom: 15px;
            font-weight: 700;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        
        .subtitle {
            font-size: 1.2em;
            opacity: 0.9;
            margin-bottom: 10px;
        }
        
        .page {
            display: none;
            padding: 0;
        }
        
        .active {
            display: block;
        }
        
        .welcome-content {
            padding: 50px 40px;
            text-align: center;
        }
        
        .welcome-icon {
            font-size: 100px;
            margin: 20px 0 30px 0;
            color: #667eea;
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
        }
        
        .feature-cards {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 25px;
            margin: 40px 0;
        }
        
        .feature-card {
            background: white;
            padding: 30px 20px;
            border-radius: 15px;
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
            border-top: 4px solid #667eea;
            transition: transform 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
        }
        
        .feature-card:nth-child(2) {
            border-top-color: #2ecc71;
        }
        
        .feature-card:nth-child(3) {
            border-top-color: #e74c3c;
        }
        
        .feature-icon {
            font-size: 40px;
            margin-bottom: 15px;
        }
        
        .feature-title {
            font-size: 1.3em;
            font-weight: 600;
            margin-bottom: 10px;
            color: #2c3e50;
        }
        
        .feature-desc {
            color: #7f8c8d;
            font-size: 0.95em;
        }
        
        .instructions {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 35px;
            border-radius: 15px;
            margin: 40px 0;
            text-align: left;
        }
        
        .instructions h2 {
            margin-bottom: 20px;
            text-align: center;
            font-size: 1.8em;
        }
        
        .rating-scale {
            display: flex;
            justify-content: space-between;
            margin: 25px 0;
            background: rgba(255,255,255,0.2);
            padding: 20px;
            border-radius: 10px;
        }
        
        .scale-item {
            text-align: center;
            flex: 1;
            padding: 15px 10px;
            border-radius: 8px;
        }
        
        .scale-value {
            font-weight: bold;
            font-size: 1.8em;
            color: white;
            margin-bottom: 8px;
        }
        
        .scale-label {
            font-size: 1em;
            color: rgba(255,255,255,0.9);
        }
        
        .btn {
            display: inline-block;
            padding: 18px 50px;
            background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
            color: white;
            border: none;
            border-radius: 50px;
            font-size: 1.2em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            margin: 30px auto;
            box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
        }
        
        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 30px rgba(46, 204, 113, 0.6);
        }
        
        .footer-note {
            text-align: center;
            margin-top: 40px;
            padding-top: 25px;
            border-top: 1px solid #ecf0f1;
            color: #7f8c8d;
            font-size: 0.9em;
        }
        
        .question-container {
            margin: 30px 0;
            padding: 30px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        }
        
        .question-text {
            font-weight: bold;
            margin-bottom: 25px;
            font-size: 1.3em;
            color: #2c3e50;
            line-height: 1.5;
        }
        
        .options {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
        }
        
        .option {
            display: flex;
            align-items: center;
        }
        
        .option input {
            display: none;
        }
        
        .option label {
            display: flex;
            align-items: center;
            width: 100%;
            padding: 18px 25px;
            background: white;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid #ecf0f1;
            font-weight: 500;
        }
        
        .option label:hover {
            background: #f8f9fa;
            border-color: #667eea;
        }
        
        .option input:checked + label {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }
        
        .option-value {
            font-weight: bold;
            font-size: 1.2em;
            margin-right: 20px;
            min-width: 35px;
        }
        
        .navigation {
            display: flex;
            justify-content: space-between;
            margin-top: 30px;
            padding: 0 30px 30px;
        }
        
        .btn-prev {
            background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
        }
        
        .btn-next {
            background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
        }
        
        .progress-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding: 20px 30px;
            background: white;
            border-radius: 15px;
        }
        
        .progress-bar {
            flex-grow: 1;
            height: 12px;
            background-color: #ecf0f1;
            border-radius: 6px;
            margin: 0 25px;
            overflow: hidden;
        }
        
        .progress-fill {
            height: 100%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 6px;
            transition: width 0.5s ease;
        }
        
        .question-counter {
            font-weight: 600;
            color: #2c3e50;
            min-width: 120px;
            text-align: center;
        }
        
        .result-container {
            padding: 30px;
        }
        
        .score-summary {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 25px;
            margin: 30px 0;
        }
        
        .summary-item {
            background: white;
            padding: 25px;
            border-radius: 15px;
            text-align: center;
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        }
        
        .summary-value {
            font-size: 2.5em;
            font-weight: bold;
            margin: 15px 0;
            color: #2c3e50;
        }
        
        .summary-label {
            font-size: 1.1em;
            color: #7f8c8d;
            font-weight: 600;
        }
        
        .section-title {
            color: #2c3e50;
            margin: 40px 0 25px 0;
            padding-bottom: 15px;
            border-bottom: 3px solid #667eea;
        }
        
        .overall-assessment {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 35px;
            border-radius: 20px;
            margin: 35px 0;
            text-align: center;
        }
        
        .overall-score {
            font-size: 4em;
            font-weight: bold;
            margin: 20px 0;
        }
        
        .overall-severity {
            font-size: 2em;
            margin-bottom: 20px;
            font-weight: 600;
        }
        
        .factor-table-container {
            background: white;
            border-radius: 15px;
            padding: 25px;
            margin: 30px 0;
        }
        
        .factor-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .factor-table th {
            background: #34495e;
            color: white;
            padding: 15px;
            text-align: center;
        }
        
        .factor-table td {
            padding: 12px 15px;
            text-align: center;
            border-bottom: 1px solid #ecf0f1;
        }
        
        .severity-indicator {
            display: inline-block;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 0.9em;
            font-weight: bold;
        }
        
        .severity-normal { background: #d4edda; color: #155724; }
        .severity-mild { background: #fff3cd; color: #856404; }
        .severity-moderate { background: #ffeaa7; color: #856404; }
        .severity-severe { background: #f8d7da; color: #721c24; }
        
        .factor-analysis {
            background: #f8f9fa;
            padding: 25px;
            border-radius: 12px;
            margin: 20px 0;
            border-left: 5px solid #667eea;
        }
        
        .factor-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .factor-name {
            font-size: 1.4em;
            font-weight: bold;
            color: #2c3e50;
        }
        
        .factor-score-display {
            font-size: 1.2em;
            color: #7f8c8d;
            font-weight: 600;
        }
        
        .factor-description {
            color: #555;
            margin-bottom: 15px;
            line-height: 1.6;
        }
        
        .interpretation {
            background: #e8f4fc;
            padding: 18px;
            border-radius: 8px;
            margin: 12px 0;
            border-left: 4px solid #3498db;
        }
        
        .suggestion {
            background: #fff9db;
            padding: 18px;
            border-radius: 8px;
            margin: 12px 0;
            border-left: 4px solid #ffd43b;
        }
        
        .score-analysis {
            background: #f0f8ff;
            padding: 25px;
            border-radius: 15px;
            margin: 30px 0;
            border-left: 6px solid #3498db;
        }
        
        .analysis-item {
            margin-bottom: 20px;
        }
        
        .analysis-title {
            font-size: 1.3em;
            font-weight: bold;
            color: #2c3e50;
            margin-bottom: 10px;
        }
        
        @media (max-width: 768px) {
            .feature-cards {
                grid-template-columns: 1fr;
            }
            
            .score-summary {
                grid-template-columns: 1fr;
            }
            
            .rating-scale {
                flex-direction: column;
                gap: 10px;
            }
            
            .factor-header {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .factor-score-display {
                margin-top: 10px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="welcomePage" class="page active">
            <header>
                <h1>SCL-90心理健康自评量表</h1>
                <p class="subtitle">症状自评量表(Self-reporting Inventory)</p>
                <p class="subtitle">专业心理测评 · 科学评估 · 个性化建议</p>
            </header>
            
            <div class="welcome-content">
                <div class="welcome-icon">🧠</div>
                
                <div class="feature-cards">
                    <div class="feature-card">
                        <div class="feature-icon">📋</div>
                        <div class="feature-title">专业测评</div>
                        <div class="feature-desc">基于国际通用的SCL-90量表，包含90道专业题目，全面评估心理健康状况</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">⚡</div>
                        <div class="feature-title">快速评估</div>
                        <div class="feature-desc">约15-20分钟完成测试，即时生成详细分析报告，了解自身心理状态</div>
                    </div>
                    <div class="feature-card">
                        <div class="feature-icon">🔒</div>
                        <div class="feature-title">隐私保护</div>
                        <div class="feature-desc">您的回答将被严格保密，测试数据仅用于生成个人评估报告</div>
                    </div>
                </div>
                
                <div class="instructions">
                    <h2>📝 测试说明</h2>
                    <p><strong>指导语：</strong>以下列出了有些人可能存在的症状或问题，请仔细阅读每一条，然后根据最近一星期以内下述问题影响您或使您感到苦恼的程度，选择最符合的选项。</p>
                    <p><strong>请根据您的真实感受作答，这将有助于获得准确的结果。</strong></p>
                    
                    <div class="rating-scale">
                        <div class="scale-item">
                            <div class="scale-value">0</div>
                            <div class="scale-label">从无</div>
                        </div>
                        <div class="scale-item">
                            <div class="scale-value">1</div>
                            <div class="scale-label">轻度</div>
                        </div>
                        <div class="scale-item">
                            <div class="scale-value">2</div>
                            <div class="scale-label">中度</div>
                        </div>
                        <div class="scale-item">
                            <div class="scale-value">3</div>
                            <div class="scale-label">偏重</div>
                        </div>
                        <div class="scale-item">
                            <div class="scale-value">4</div>
                            <div class="scale-label">严重</div>
                        </div>
                    </div>
                </div>
                
                <button class="btn" id="startBtn">开始测试</button>
                
                <div class="footer-note">
                    <p>💡 温馨提示：本测试共有90道题目，建议在安静环境中花费15-20分钟完成</p>
                    <p>🔒 您的隐私安全受保护，测试结果仅用于自我评估参考</p>
                </div>
            </div>
        </div>
        
        <div id="questionPage" class="page">
            <header>
                <h1>SCL-90心理健康测试</h1>
                <p class="subtitle">请根据您的实际情况选择最符合的选项</p>
            </header>
            
            <div class="progress-container">
                <div class="question-counter" id="questionCounter">题目 1/90</div>
                <div class="progress-bar">
                    <div class="progress-fill" id="progressFill"></div>
                </div>
                <div id="progressPercent">1%</div>
            </div>
            
            <div class="question-container">
                <div class="question-text" id="questionText">问题加载中...</div>
                <div class="options" id="optionsContainer"></div>
            </div>
            
            <div class="navigation">
                <button class="btn btn-prev" id="prevBtn" style="display: none;">上一题</button>
                <button class="btn btn-next" id="nextBtn">下一题</button>
            </div>
        </div>
        
        <div id="resultPage" class="page">
            <header>
                <h1>SCL-90测评结果报告</h1>
                <p class="subtitle">基于您的自评数据生成的详细分析报告</p>
            </header>
            
            <div class="result-container">
                <div class="overall-assessment">
                    <h2>总体评估结果</h2>
                    <div class="overall-score" id="overallScore">0</div>
                    <div class="overall-severity" id="overallSeverity">正常</div>
                    <div id="overallText">评估结果加载中...</div>
                </div>
                
                <h3 class="section-title">测试数据总览</h3>
                <div class="score-summary">
                    <div class="summary-item">
                        <div class="summary-label">总分</div>
                        <div class="summary-value" id="totalScore">0</div>
                        <div class="summary-desc">所有题目得分总和</div>
                    </div>
                    <div class="summary-item">
                        <div class="summary-label">阳性项目数</div>
                        <div class="summary-value" id="positiveItems">0</div>
                        <div class="summary-desc">得分≥1的题目数量</div>
                    </div>
                    <div class="summary-item">
                        <div class="summary-label">阳性症状均分</div>
                        <div class="summary-value" id="positiveAverage">0.00</div>
                        <div class="summary-desc">总分/阳性项目数</div>
                    </div>
                </div>
                
                <!-- 新增：总分和阳性项目详细分析 -->
                <div class="score-analysis">
                    <h3 class="section-title">📊 综合指标分析</h3>
                    
                    <div class="analysis-item">
                        <div class="analysis-title">总分分析</div>
                        <div id="totalScoreAnalysis" class="interpretation">总分分析结果加载中...</div>
                        <div id="totalScoreSuggestion" class="suggestion">总分建议加载中...</div>
                    </div>
                    
                    <div class="analysis-item">
                        <div class="analysis-title">阳性项目数分析</div>
                        <div id="positiveItemsAnalysis" class="interpretation">阳性项目数分析结果加载中...</div>
                        <div id="positiveItemsSuggestion" class="suggestion">阳性项目数建议加载中...</div>
                    </div>
                    
                    <div class="analysis-item">
                        <div class="analysis-title">阳性症状均分分析</div>
                        <div id="positiveAverageAnalysis" class="interpretation">阳性症状均分分析结果加载中...</div>
                        <div id="positiveAverageSuggestion" class="suggestion">阳性症状均分建议加载中...</div>
                    </div>
                </div>
                
                <h3 class="section-title">各因子得分详情</h3>
                <div class="factor-table-container">
                    <table class="factor-table">
                        <thead>
                            <tr>
                                <th>心理因子</th>
                                <th>总分</th>
                                <th>平均分</th>
                                <th>严重程度</th>
                            </tr>
                        </thead>
                        <tbody id="factorTableBody"></tbody>
                    </table>
                </div>
                
                <h3 class="section-title">各维度详细分析</h3>
                <div id="factorDetailedAnalysis"></div>
                
                <div style="background: #fff9db; padding: 30px; border-radius: 15px; margin-top: 40px; border-left: 6px solid #ffd43b;">
                    <h3 style="color: #e67700; margin-bottom: 20px;">💡 重要提示</h3>
                    <p style="margin-bottom: 15px;">本报告基于您的自评数据生成，可作为心理状态的参考，但不能替代专业医生的诊断。</p>
                    <p style="margin-bottom: 15px;">如果某些结果让您感到担忧，建议与心理咨询师或精神科医生进一步沟通。</p>
                    <p>请用从容的心态来看待本次测评。无论分数如何，请一定记得，我们始终都在你身边。</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 完整的SCL-90问题列表
        const questions = [
            "头痛", "神经过敏，心中不踏实", "头脑中有不必要的想法或字句盘旋", "头晕或昏倒", "对异性的兴趣减退",
            "对旁人责备求全", "感到别人能控制您的思想", "责怪别人制造麻烦", "忘记性大", "担心自己的衣饰整齐及仪态的端正",
            "容易烦恼和激动", "胸痛", "害怕空旷的场所或街道", "感到自己的精力下降，活动减慢", "想结束自己的生命",
            "听到旁人听不到的声音", "发抖", "感到大多数人都不可信任", "胃口不好", "容易哭泣",
            "同异性相处时感到害羞不自在", "感到受骗，中了圈套或有人想抓住您", "无缘无故地突然感到害怕", "自己不能控制地大发脾气", "怕单独出门",
            "经常责怪自己", "腰痛", "感到难以完成任务", "感到孤独", "感到苦闷",
            "过分担忧", "对事物不感兴趣", "感到害怕", "您的感情容易受到伤害", "旁人能知道您的私下想法",
            "感到别人不理解您、不同情您", "感到人们对您不友好，不喜欢您", "做事必须做得很慢以保证做得正确", "心跳得很厉害", "恶心或胃部不舒服",
            "感到比不上他人", "肌肉酸痛", "感到有人在监视您、谈论您", "难以入睡", "做事必须反复检查",
            "难以作出决定", "怕乘电车、公共汽车、地铁或火车", "呼吸有困难", "一阵阵发冷或发热", "因为感到害怕而避开某些东西、场合或活动",
            "脑子变空了", "身体发麻或刺痛", "喉咙有梗塞感", "感到前途没有希望", "不能集中注意",
            "感到身体的某一部分软弱无力", "感到紧张或容易紧张", "感到手或脚发重", "想到死亡的事", "吃得太多",
            "当别人看着您或谈论您时感到不自在", "有一些不属于您自己的想法", "有想打人或伤害他人的冲动", "醒得太早", "必须反复洗手、点数或触摸某些东西",
            "睡得不稳不深", "有想摔坏或破坏东西的冲动", "有一些别人没有的想法或念头", "感到对别人神经过敏", "在商店或电影院等人多的地方感到不自在",
            "感到任何事情都很困难", "一阵阵恐惧或惊恐", "感到在公共场合吃东西很不舒服", "经常与人争论", "单独一人时神经很紧张",
            "别人对您的成绩没有作出恰当的评价", "即使和别人在一起也感到孤单", "感到坐立不安心神不定", "感到自己没有什么价值", "感到熟悉的东西变成陌生或不像是真的",
            "大叫或摔东西", "害怕会在公共场合昏倒", "感到别人想占您的便宜", "为一些有关\"性\"的想法而很苦恼", "您认为应该因为自己的过错而受到惩罚",
            "感到要很快把事情做完", "感到自己的身体有严重问题", "从未感到和其他人很亲近", "感到自己有罪", "感到自己的脑子有毛病"
        ];

        // SCL-90因子分组 (题目索引从0开始)
        const factors = {
            "躯体化": [0, 1, 4, 12, 27, 40, 42, 48, 49, 52, 53, 56, 58],
            "强迫症状": [3, 9, 10, 28, 38, 45, 46, 51, 55, 65],
            "人际关系敏感": [6, 21, 34, 36, 37, 41, 61, 69, 73],
            "抑郁": [5, 14, 15, 20, 22, 26, 29, 30, 31, 32, 54, 71, 79],
            "焦虑": [2, 17, 23, 33, 39, 57, 72, 78, 80, 86],
            "敌对": [11, 24, 63, 67, 74, 81],
            "恐怖": [13, 25, 47, 50, 70, 75, 82],
            "偏执": [8, 18, 43, 68, 76, 83],
            "精神病性": [7, 16, 35, 62, 77, 84, 85, 87, 88, 89],
            "其他": [19, 44, 59, 60, 64, 66]
        };

        // 因子描述和建议
        const factorDetails = {
            "躯体化": {
                description: "主要反映主观的身体不适感，包括心血管、胃肠道、呼吸系统的不适，以及头痛、背痛、肌肉酸痛等其他躯体表现。",
                interpretation: {
                    normal: "您的躯体化症状在正常范围内，身体不适感较少。",
                    mild: "您有轻度的躯体不适感，可能与压力或情绪状态有关。",
                    moderate: "您有中度的躯体不适症状，建议关注身心健康，适当放松。",
                    severe: "您的躯体不适症状较为明显，建议寻求专业医疗帮助。"
                },
                suggestion: "学习放松技巧如深呼吸、渐进式肌肉放松，保持规律作息，适当运动。如果症状持续，建议咨询医生排除器质性疾病。"
            },
            "强迫症状": {
                description: "主要指那些明知没有必要，但又无法摆脱的无意义的思想、冲动和行为。",
                interpretation: {
                    normal: "您的强迫症状在正常范围内，思维和行为较为自然。",
                    mild: "您有轻度的强迫症状，偶尔会出现不必要的想法或行为。",
                    moderate: "您有中度的强迫症状，可能对日常生活造成一定影响。",
                    severe: "您的强迫症状较为严重，建议寻求专业心理咨询。"
                },
                suggestion: "尝试认知行为疗法技巧，学习接纳不完美，减少重复检查行为。当强迫思维出现时，尝试转移注意力到其他活动上。"
            },
            "人际关系敏感": {
                description: "主要指个人不自在感和自卑感，尤其是在与他人比较时更加突出。",
                interpretation: {
                    normal: "您的人际关系敏感度在正常范围内，社交互动较为舒适。",
                    mild: "您在人际交往中有些敏感，偶尔会感到不自在。",
                    moderate: "您对人际关系较为敏感，可能影响社交质量。",
                    severe: "您的人际关系敏感度较高，社交互动可能带来较大压力。"
                },
                suggestion: "参加社交技能训练，学习积极自我对话，逐步扩大社交圈。尝试记录自己的优点和成就，增强自信心。"
            },
            "抑郁": {
                description: "反映与临床抑郁症状相联系的广泛概念，包括心境低落、生活兴趣减退、缺乏动力等。",
                interpretation: {
                    normal: "您的抑郁症状在正常范围内，情绪状态较为稳定。",
                    mild: "您有轻度的抑郁情绪，偶尔会感到情绪低落。",
                    moderate: "您有中度的抑郁症状，建议关注情绪健康。",
                    severe: "您的抑郁症状较为明显，强烈建议寻求专业帮助。"
                },
                suggestion: "保持规律作息，增加户外活动，与亲友保持联系，必要时寻求专业心理咨询。尝试记录每天的小确幸，培养感恩心态。"
            },
            "焦虑": {
                description: "包括烦躁、坐立不安、紧张、焦虑等主观体验及相关躯体症状。",
                interpretation: {
                    normal: "您的焦虑症状在正常范围内，情绪较为平稳。",
                    mild: "您有轻度的焦虑症状，偶尔会感到紧张不安。",
                    moderate: "您有中度的焦虑症状，可能影响日常生活。",
                    severe: "您的焦虑症状较为严重，建议寻求专业帮助。"
                },
                suggestion: "练习深呼吸和正念冥想，合理安排时间，减少咖啡因摄入。当焦虑出现时，尝试将注意力集中在当下，避免过度思考未来。"
            },
            "敌对": {
                description: "主要从思想、情感和行为三个方面反映敌对表现，包括厌烦、争论、脾气难以控制等。",
                interpretation: {
                    normal: "您的敌对情绪在正常范围内，能够较好地控制情绪。",
                    mild: "您有轻度的敌对情绪，偶尔会感到烦躁易怒。",
                    moderate: "您有中度的敌对情绪，可能影响人际关系。",
                    severe: "您的敌对情绪较为明显，建议学习情绪管理技巧。"
                },
                suggestion: "学习愤怒管理技巧，通过运动释放压力，练习有效沟通。当感到愤怒时，尝试暂停10秒再回应，给自己冷静的时间。"
            },
            "恐怖": {
                description: "反映对某些场所、事物或情境的恐惧和回避行为。",
                interpretation: {
                    normal: "您的恐怖症状在正常范围内，对环境的适应良好。",
                    mild: "您有轻度的恐怖症状，对某些情境会感到不适。",
                    moderate: "您有中度的恐怖症状，可能影响正常活动。",
                    severe: "您的恐怖症状较为明显，建议寻求专业帮助。"
                },
                suggestion: "尝试渐进式暴露疗法，学习放松技巧应对恐惧情境。可以从想象恐惧场景开始，逐步过渡到面对真实情境。"
            },
            "偏执": {
                description: "主要指猜疑和关系妄想等思维内容障碍。",
                interpretation: {
                    normal: "您的偏执症状在正常范围内，思维较为理性。",
                    mild: "您有轻度的偏执倾向，偶尔会多疑。",
                    moderate: "您有中度的偏执症状，可能影响人际关系。",
                    severe: "您的偏执症状较为明显，建议寻求专业评估。"
                },
                suggestion: "练习现实检验，与信任的人讨论自己的想法，保持开放心态。当产生怀疑时，尝试寻找客观证据支持或反驳自己的想法。"
            },
            "精神病性": {
                description: "包括幻听、思维播散、被控制感等精神分裂症状。",
                interpretation: {
                    normal: "您的精神病性症状在正常范围内。",
                    mild: "您有轻度的精神病性症状，建议关注思维变化。",
                    moderate: "您有中度的精神病性症状，建议寻求专业评估。",
                    severe: "您的精神病性症状较为明显，强烈建议尽快寻求专业帮助。"
                },
                suggestion: "及时寻求精神科专业评估，保持规律治疗，建立支持系统。与家人或朋友保持沟通，让他们了解您的状况。"
            },
            "其他": {
                description: "主要反映睡眠和饮食等方面的问题。",
                interpretation: {
                    normal: "您的睡眠和饮食状况在正常范围内。",
                    mild: "您在睡眠或饮食方面有轻度困扰。",
                    moderate: "您在睡眠或饮食方面有中度困扰。",
                    severe: "您的睡眠或饮食困扰较为严重，影响日常生活。"
                },
                suggestion: "建立规律的作息时间，注意均衡饮食，创造舒适的睡眠环境。避免睡前使用电子设备，尝试放松活动如阅读或听轻音乐。"
            }
        };

        // 全局变量
        let currentQuestion = 0;
        const answers = new Array(questions.length).fill(null);

        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const welcomePage = document.getElementById('welcomePage');
            const questionPage = document.getElementById('questionPage');
            const resultPage = document.getElementById('resultPage');
            const questionText = document.getElementById('questionText');
            const optionsContainer = document.getElementById('optionsContainer');
            const prevBtn = document.getElementById('prevBtn');
            const nextBtn = document.getElementById('nextBtn');
            const startBtn = document.getElementById('startBtn');

            // 开始测试按钮事件
            startBtn.addEventListener('click', function() {
                welcomePage.classList.remove('active');
                questionPage.classList.add('active');
                loadQuestion(0);
            });

            // 下一题按钮事件
            nextBtn.addEventListener('click', function() {
                if (answers[currentQuestion] === null) {
                    alert('请选择答案后再继续！');
                    return;
                }
                
                if (currentQuestion < questions.length - 1) {
                    loadQuestion(currentQuestion + 1);
                } else {
                    calculateResults();
                }
            });

            // 上一题按钮事件
            prevBtn.addEventListener('click', function() {
                if (currentQuestion > 0) {
                    loadQuestion(currentQuestion - 1);
                }
            });

            // 加载问题函数
            function loadQuestion(index) {
                currentQuestion = index;
                questionText.textContent = `${index + 1}. ${questions[index]}`;
                
                // 更新计数器
                document.getElementById('questionCounter').textContent = `题目 ${index + 1}/${questions.length}`;
                
                // 更新进度条
                const progress = ((index + 1) / questions.length) * 100;
                document.getElementById('progressFill').style.width = `${progress}%`;
                document.getElementById('progressPercent').textContent = `${Math.round(progress)}%`;
                
                // 清空选项
                optionsContainer.innerHTML = '';
                
                // 生成选项
                const optionTexts = ["从无", "轻度", "中度", "偏重", "严重"];
                
                for (let i = 0; i <= 4; i++) {
                    const optionDiv = document.createElement('div');
                    optionDiv.className = 'option';
                    
                    const input = document.createElement('input');
                    input.type = 'radio';
                    input.name = 'question';
                    input.value = i;
                    input.id = `option${i}`;
                    
                    if (answers[index] === i) {
                        input.checked = true;
                    }
                    
                    input.addEventListener('change', function() {
                        answers[index] = parseInt(this.value);
                    });
                    
                    const label = document.createElement('label');
                    label.htmlFor = `option${i}`;
                    
                    const valueSpan = document.createElement('span');
                    valueSpan.className = 'option-value';
                    valueSpan.textContent = i;
                    
                    const textSpan = document.createElement('span');
                    textSpan.className = 'option-text';
                    textSpan.textContent = optionTexts[i];
                    
                    label.appendChild(valueSpan);
                    label.appendChild(textSpan);
                    
                    optionDiv.appendChild(input);
                    optionDiv.appendChild(label);
                    optionsContainer.appendChild(optionDiv);
                }
                
                // 更新按钮状态
                prevBtn.style.display = index === 0 ? 'none' : 'inline-block';
                nextBtn.textContent = index === questions.length - 1 ? '提交测试' : '下一题';
            }

            // 计算结果函数
            function calculateResults() {
                // 计算总分
                let totalScore = 0;
                for (let i = 0; i < answers.length; i++) {
                    totalScore += answers[i] || 0;
                }
                
                // 计算阳性项目数
                let positiveItems = 0;
                for (let i = 0; i < answers.length; i++) {
                    if (answers[i] > 0) {
                        positiveItems++;
                    }
                }
                
                // 计算阳性症状均分
                const positiveSymptomAverage = positiveItems > 0 ? (totalScore / positiveItems).toFixed(2) : "0.00";
                
                // 计算因子得分
                const factorScores = calculateFactorScores();
                
                // 显示结果
                displayResults(totalScore, positiveItems, positiveSymptomAverage, factorScores);
                
                // 切换到结果页面
                questionPage.classList.remove('active');
                resultPage.classList.add('active');
            }

            // 计算因子得分
            function calculateFactorScores() {
                const factorScores = {};
                
                for (const [factorName, questionIndices] of Object.entries(factors)) {
                    let factorTotal = 0;
                    let factorCount = 0;
                    
                    for (const index of questionIndices) {
                        if (answers[index] !== null) {
                            factorTotal += answers[index];
                            factorCount++;
                        }
                    }
                    
                    const averageScore = factorCount > 0 ? (factorTotal / factorCount).toFixed(2) : 0;
                    
                    factorScores[factorName] = {
                        total: factorTotal,
                        average: parseFloat(averageScore),
                        count: factorCount
                    };
                }
                
                return factorScores;
            }

            // 获取严重程度
            function getSeverity(score) {
                if (score < 1.5) return { level: "正常", class: "severity-normal" };
                if (score < 2.5) return { level: "轻度", class: "severity-mild" };
                if (score < 3.5) return { level: "中度", class: "severity-moderate" };
                return { level: "重度", class: "severity-severe" };
            }

            // 显示结果函数
            function displayResults(totalScore, positiveItems, positiveSymptomAverage, factorScores) {
                // 更新总分和统计信息
                document.getElementById('totalScore').textContent = totalScore;
                document.getElementById('positiveItems').textContent = positiveItems;
                document.getElementById('positiveAverage').textContent = positiveSymptomAverage;
                document.getElementById('overallScore').textContent = totalScore;
                
                // 总体评估
                let overallAssessment = "";
                let overallSeverity = "";
                
                if (totalScore < 160) {
                    overallAssessment = "根据您的测试结果，总体心理健康状况良好。您的总分在正常范围内，表明您最近一周的心理困扰程度较低。";
                    overallSeverity = "正常";
                } else if (totalScore < 225) {
                    overallAssessment = "根据您的测试结果，总体心理健康状况处于轻度困扰水平。您可能在某些方面感到不适，但整体功能未受严重影响。建议关注自身情绪变化，适当调整生活方式。";
                    overallSeverity = "轻度";
                } else if (totalScore < 315) {
                    overallAssessment = "根据您的测试结果，总体心理健康状况处于中度困扰水平。您可能在某些方面感到明显不适，建议寻求专业心理咨询师的帮助，以获得更针对性的支持。";
                    overallSeverity = "中度";
                } else {
                    overallAssessment = "根据您的测试结果，总体心理健康状况处于重度困扰水平。您可能正经历显著的心理痛苦，强烈建议尽快寻求专业心理健康服务，以获得及时有效的帮助。";
                    overallSeverity = "重度";
                }
                
                document.getElementById('overallSeverity').textContent = overallSeverity;
                document.getElementById('overallText').textContent = overallAssessment;
                
                // 新增：总分详细分析
                let totalScoreAnalysis = "";
                let totalScoreSuggestion = "";
                
                if (totalScore < 160) {
                    totalScoreAnalysis = "您的总分为" + totalScore + "分，低于160分的临界值，表明您当前的心理健康状况良好。您最近一周的心理困扰程度较低，整体功能良好。";
                    totalScoreSuggestion = "继续保持良好的心理状态，注意日常压力管理，维持健康的生活方式。";
                } else if (totalScore < 225) {
                    totalScoreAnalysis = "您的总分为" + totalScore + "分，处于160-224分的轻度困扰范围。这表明您最近一周存在一定程度的心理困扰，但整体功能尚未受到严重影响。";
                    totalScoreSuggestion = "建议关注自身情绪变化，学习压力管理技巧，适当调整生活方式。如果困扰持续存在，可考虑寻求专业心理支持。";
                } else if (totalScore < 315) {
                    totalScoreAnalysis = "您的总分为" + totalScore + "分，处于225-314分的中度困扰范围。这表明您最近一周存在明显的心理困扰，可能对日常生活造成了一定影响。";
                    totalScoreSuggestion = "建议寻求专业心理咨询师的帮助，进行更深入的评估和干预。同时，学习情绪调节技巧，建立支持系统。";
                } else {
                    totalScoreAnalysis = "您的总分为" + totalScore + "分，达到315分以上的重度困扰水平。这表明您最近一周正经历显著的心理痛苦，可能严重影响日常生活功能。";
                    totalScoreSuggestion = "强烈建议尽快寻求专业心理健康服务，进行全面评估和系统干预。请记住，寻求帮助是勇敢和明智的选择。";
                }
                
                document.getElementById('totalScoreAnalysis').textContent = totalScoreAnalysis;
                document.getElementById('totalScoreSuggestion').textContent = totalScoreSuggestion;
                
                // 新增：阳性项目数详细分析
                let positiveItemsAnalysis = "";
                let positiveItemsSuggestion = "";
                
                if (positiveItems < 43) {
                    positiveItemsAnalysis = "您的阳性项目数为" + positiveItems + "个，低于43个的参考标准。这表明您报告的症状数量较少，心理困扰的范围相对有限。";
                    positiveItemsSuggestion = "继续保持良好的心理状态，关注已出现的轻度症状，预防其进一步发展。";
                } else if (positiveItems < 60) {
                    positiveItemsAnalysis = "您的阳性项目数为" + positiveItems + "个，处于43-59个的中等范围。这表明您报告的症状数量适中，存在一定范围的心理困扰。";
                    positiveItemsSuggestion = "建议关注这些症状对生活的影响，学习应对技巧，适当进行心理调适。如果症状持续，可考虑专业评估。";
                } else {
                    positiveItemsAnalysis = "您的阳性项目数为" + positiveItems + "个，达到60个以上的较高水平。这表明您报告的症状数量较多，心理困扰的范围较广。";
                    positiveItemsSuggestion = "建议寻求专业心理咨询，进行全面评估和针对性干预。重点关注对日常生活影响最大的症状领域。";
                }
                
                document.getElementById('positiveItemsAnalysis').textContent = positiveItemsAnalysis;
                document.getElementById('positiveItemsSuggestion').textContent = positiveItemsSuggestion;
                
                // 新增：阳性症状均分详细分析
                let positiveAverageAnalysis = "";
                let positiveAverageSuggestion = "";
                const positiveAvg = parseFloat(positiveSymptomAverage);
                
                if (positiveAvg < 2.0) {
                    positiveAverageAnalysis = "您的阳性症状均分为" + positiveSymptomAverage + "分，低于2.0分的参考标准。这表明您报告的症状平均强度较低，困扰程度相对较轻。";
                    positiveAverageSuggestion = "继续保持良好的应对方式，关注症状变化，预防其强度增加。";
                } else if (positiveAvg < 3.0) {
                    positiveAverageAnalysis = "您的阳性症状均分为" + positiveSymptomAverage + "分，处于2.0-2.9分的中等强度范围。这表明您报告的症状平均强度适中，存在一定程度的困扰。";
                    positiveAverageSuggestion = "建议学习更有效的应对策略，关注高强度症状的管理，必要时寻求专业支持。";
                } else {
                    positiveAverageAnalysis = "您的阳性症状均分为" + positiveSymptomAverage + "分，达到3.0分以上的较高强度水平。这表明您报告的症状平均强度较高，困扰程度较为明显。";
                    positiveAverageSuggestion = "强烈建议寻求专业心理帮助，重点管理高强度症状，制定个性化的干预计划。";
                }
                
                document.getElementById('positiveAverageAnalysis').textContent = positiveAverageAnalysis;
                document.getElementById('positiveAverageSuggestion').textContent = positiveAverageSuggestion;
                
                // 更新因子得分表格
                const factorTableBody = document.getElementById('factorTableBody');
                factorTableBody.innerHTML = '';
                
                for (const [factorName, scoreData] of Object.entries(factorScores)) {
                    const severity = getSeverity(scoreData.average);
                    
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${factorName}</td>
                        <td>${scoreData.total}</td>
                        <td>${scoreData.average}</td>
                        <td><span class="severity-indicator ${severity.class}">${severity.level}</span></td>
                    `;
                    factorTableBody.appendChild(row);
                }
                
                // 更新各维度详细分析
                const factorDetailedAnalysis = document.getElementById('factorDetailedAnalysis');
                factorDetailedAnalysis.innerHTML = '';
                
                for (const [factorName, scoreData] of Object.entries(factorScores)) {
                    const severity = getSeverity(scoreData.average);
                    const detail = factorDetails[factorName];
                    
                    let interpretationText = "";
                    if (scoreData.average < 1.5) {
                        interpretationText = detail.interpretation.normal;
                    } else if (scoreData.average < 2.5) {
                        interpretationText = detail.interpretation.mild;
                    } else if (scoreData.average < 3.5) {
                        interpretationText = detail.interpretation.moderate;
                    } else {
                        interpretationText = detail.interpretation.severe;
                    }
                    
                    const analysisDiv = document.createElement('div');
                    analysisDiv.className = 'factor-analysis';
                    analysisDiv.innerHTML = `
                        <div class="factor-header">
                            <div class="factor-name">${factorName}</div>
                            <div class="factor-score-display">得分: ${scoreData.average} | 严重程度: <span class="severity-indicator ${severity.class}">${severity.level}</span></div>
                        </div>
                        <div class="factor-description">${detail.description}</div>
                        <div class="interpretation">${interpretationText}</div>
                        <div class="suggestion">${detail.suggestion}</div>
                    `;
                    factorDetailedAnalysis.appendChild(analysisDiv);
                }
            }
        });
    </script>
</body>
</html>